package test.invoke;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.MethodHandle;

public class Son extends Father {
    void thinking() {
        try {
            // 实现调用祖父类的thinking()方法，打印"i am grandfather"
            MethodType mt = MethodType.methodType(void.class);
            MethodHandle mh = MethodHandles.lookup().findSpecial(GrandFather.class,"thinking", mt, getClass());
            mh.invoke(this);
        } catch (Throwable e) {
        }
    }

    public static void main(String[] args) {
        (new Son()).thinking();
    }
}